<template>
  <view class="fixedTop">
    <view class="top-nav-box">
      <view class="nav-back" @click="navBack()">
        <view class="image-wrapper"><image src="@/static/img/black-back.png" mode="aspectFit"></image></view>
      </view>
      <template>
        <view class="nav-txt flex1">
          <view class="type-item">余额明细</view>
        </view>
        <view class="nav-right">
          <template>
            <view class="image-wrapper2" @click="$emit('openMingxi')"><image src="@/static/img/order-ques.png" mode="aspectFit"></image></view>
          </template>
        </view>
      </template>
      <slot></slot>
    </view>
  </view>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex';
export default {
  props:{
    title:{
      type: String,
      default: ''
    },
    isOrder: {
      type: String,
      default: '1'
    },
  },
  computed: {
    ...mapGetters(['userInfo'])
  },
  data() {
    return {};
  },
  created() {this.gettopColor()},
  methods: {
    navBack() {
      if (this.title == '邀请好友') {
        uni.navigateBack({
          delta: 1
        });
      } else {
        const nav = navigator.userAgent;
        if (nav.indexOf('Android') > -1 || nav.indexOf('Adr') > -1) {
          phone.onBackPress();
        } else if (!!nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
          this.$bridge.callhandler('onBackPress', {}, res => {});
        }
      }
    },
    //判断顶部颜色
    gettopColor(){
      const nav = navigator.userAgent;
      if (nav.indexOf('Android') > -1 || nav.indexOf('Adr') > -1) {
        phone.setStatusBarColor("#ffffff")
      } else if (!!nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        this.$bridge.callhandler('backgroundColorChange', {topColor:'#ffffff',bottomColor:"#ffffff"}, res => {});
      }
    },
  }
};
</script>

<style lang="scss">
.top-nav-box {
  background: #fff;
  color: #000;
  text-align: center;
  position: relative;
  height: 88rpx;
  line-height: 88rpx;
  font-size: 32rpx;
  display: flex;
  width: 100%;
  .nav-txt {
    font-size: 32rpx;
  }
  .flex1{
    display: flex;
    align-items: center;
    justify-content: center;
    .type-item:first-child{
      font-size: 16px;
    }
  }
  .nav-back {
    width: 88rpx;
    height: 88rpx;
    position: absolute;
    top: 0;
    left: 0;
    .image-wrapper {
      margin-left: 14rpx;
      box-sizing: border-box;
      width: 34rpx;
      height: 34rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
  }
  .nav-right {
    display: flex;
    padding-right: 20rpx;
    position: absolute;
    top: 0;
    right: 0;
    .image-wrapper {
      margin-top: 10rpx;
      margin-right: 20rpx;
      width: 70rpx;
      height: 70rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
    .image-wrapper2 {
      margin-top: 10rpx;
      width: 40rpx;
      height: 40rpx;
      image {
        width: 100%;
        height: 100%;
      }
    }
    .nar-right-txt {
      font-size: 32rpx;
    }
  }
}
</style>
